package com.vcredit.creditcat.web.app;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vcredit.creditcat.api.IMyWalletManager;
import com.vcredit.creditcat.dto.wallet.WalletAmtInOutLogDto;
import com.vcredit.creditcat.dto.wallet.WalletDrawInputDto;
import com.vcredit.creditcat.dto.wallet.WalletIndexDto;
import com.vcredit.creditcat.vo.JsonResult;


/**
 * 我的钱包
 * @author zhaoqi01
 *
 */
@RestController
@RequestMapping("myWallet")
public class MyWalletController extends BaseCreditCatController{
	
	@Reference(version="1.0")
	private IMyWalletManager myWalletManager;
	
	/**
	 * 钱包首页
	 * @author zhaoqi01
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("index")
	public WalletIndexDto index(HttpServletRequest request) throws Exception {
		WalletIndexDto WalletIndexDto = myWalletManager.index(super.getCust(request).getCustId());
		return WalletIndexDto;
	}

	/**
	 * 钱包提现
	 * @author zhaoqi01
	 * @param param
	 * @param request
	 * @throws Exception 
	 */
	@RequestMapping("drawAmt")
	public JsonResult drawAmt(@Valid @RequestBody WalletDrawInputDto param,HttpServletRequest request) throws Exception {
		myWalletManager.drawAmt(param,super.getCust(request).getCustId());
		return new JsonResult(null);
	}
	
	@RequestMapping("amtHistory")
	public WalletAmtInOutLogDto walletAmtHisTory(HttpServletRequest request) {
		return myWalletManager.walletAmtHisTory(super.getCust(request).getCustId());
	}
}
